home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991: Code Warrior / bincue / Code Warrior.bin / Tools & Apps (Moof!) / OS⁄Toolbox / Apple Events / Init for Apple Events 1.0 / about AEMGenSysHandlerLoader next >
Encoding:
Text File  |  1991-06-24  |  4.6 KB  |  37 lines  |  [TEXT/ttxt]

  1. AEMGenSysHandlerLoader is a INIT for loading a whole set of AppleEvent handlers into the system heap at INIT time. It is similar to the install function in the AEHandlerInfo FKEY in the sense it assumes that each handler resides in a single code resource with the entry point being the beginning of the code resource. The difference between the are that
  2.  
  3. The INIT can only load handler at boot time, the FKEY can do it any time.
  4.  
  5. The INIT only loads to system heap, the FKEY can do it to either the system  heap or the application heap.
  6.  
  7. The INIT can load more types of code resource. For example there is a loader for use with XCMD and XFCN. Since the loader is just another code resource, other type of code resource may also be added in future. The FKEY current does not have this capability.
  8.  
  9. In general the INIT is used for loading up your system at boot time with handlers that are useful for you and the FKEY is used to load a code resource on demand for testing purpose.
  10.  
  11. AEMGenSysHandlerLoader comes as a control panel device so you may activate/deactivate, remove and add individual handlers. However such editing would not be effective immediately, rather they would affect what happens in the next boot. Each active handler will have • in front of it so you can tell which ones are active. The add function let you copy the appropriate code resources from another file (of course you can also use ResEdit to do the job).
  12.  
  13. Writing a code resource handler is no different from writing any other code resource but you must name the resource using our naming convention. Code resource that will be loaded directly will be of the resource type ‘PROC’. The first four character of the name must be either ‘AEVT’, ‘CSDS’, ‘CSPT’, ‘SPEC’, ‘TRAP’.
  14.  
  15. The rest of the name depends on the first four characters, and the name may have comments after ‘:’. The name may also contains a chaining offset which would be at the end of the name just before the comment. It is a four digit hexadecimal number. If a handler of the same kind is already loaded into the system, we would load in the new handler, but store the address of the old handler into the beginning of the new handler plus the chaining offset.
  16.  
  17. ‘AEVT’ - this is an AppleEvent handler. The next eight characters are the event class and event ID.
  18.  
  19. ‘CSDS’ and ‘CSPT’ - they are the coercion handler of types descriptor to descriptor and pointer to descriptor. The next eight characters are the from type and the to type.
  20.  
  21. ‘SPEC’ - this is the special handlers, the next four characters are the keyword for the special function.
  22.  
  23. ‘TRAP’ - this is for patching the toolbox, the next four characters are the toolbox trap number in hexadecimal.
  24.  
  25. There is also a special loader for XCMD/XFCN, they must be renamed but the resource type would stay as XCMD/XFCN. The first eight characters of the name are the event class and event ID. Following that every four characters represents the keyword of a parameter. When an AppleEvent comes in, the keyword parameters in the AppleEvent would be translated into the positional parameter for the XCMD. As usual anything thing beyond ‘:’ is just comment. Chaining is not supported.
  26.  
  27. We have a few sample AppleEvent handlers that comes with the INIT to illustrate the idea. They are not necessary a good or even bug free implementation. They are hardly tested, so use with caution. They are all disabled so you need to activate them to try it out (after reboot).
  28.  
  29. XCMD - FLSH, this is the familiar flash command binary taken from HyperCard with only a name change. The direct object is a number for the number of times to flash.
  30.  
  31. Event handler to execute a FKEY - the event class is FKEY and the event ID is a either a hexadecimal number of the FKEY number, or it is ‘NAME’ in which case the direct object is the name of the FKEY resource. The event handler would execute the FKEY.
  32.  
  33. CSPTTEXTtarg - this is a coercion handler to coerce an application name into a target ID. This is written by Laile DiSilvestro. This is a very useful coercion handler that you will need in any scripting language where you specify an application as a text string. This include the MPW tool SendAE. You may use it to address a remote application using the format "zone:machine:application". Remember it comes disabled so you need to enable it.
  34.  
  35. TRAPA9FD - this is a highly experimental patch to the GetScrap trap call. In this patch, if the GetScrap call cannot find the type you want in the scrap, it would try to coerce the scrap data to the type you want. For example, if you have a ICON in the scrap and you ask for a PICT, then the normal GetScrap would fail, but if you happen to have a ICON to PICT coercion handler, it would give you back a PICT converted from the ICON.
  36.  
  37.